﻿<template>
    <div class="layout-main">
        <el-row style="margin-bottom:12px">
            <el-button size="small" v-on:click="add()" type="primary">添加</el-button>
        </el-row>
        <Table :loading="loading" :columns="columns" :data="wxMsgReplys" border>
        </Table>
        <div style="margin: 10px;overflow: hidden">
            <div style="float: right;">
                <Page :page-size="page.pageSize" show-total :total="page.total" :current="page.current" @on-change="changePage"></Page>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    name: 'WxMsgReply',
    data() {
        return {
            loading: false,

            queryParams: {

            },
            others: {

            },
            wxMsgReply: {

            },
            page: {
                total: 0,
                current: 1,
                pageSize: 10
            },
            wxMsgReplys: [

            ],
            roles: [],
            columns: [{
                    title: '关键字',
                    key: 'key',
                    width: 130,
                    align: 'center'
                }, {
                    title: '回复内容',
                    key: 'content',

                    align: 'center'
                },
                {
                    title: '备注',
                    key: 'remark',
                    width: 130,
                    align: 'center'
                }, {
                    title: '类型',
                    key: 'type',
                    width: 130,
                    align: 'center',
                    render: (h, params) => {
                        var row = params.row;
                        var text = "系统预定义";
                        var styles = { color: '#fff', padding: '2px' };
                        if (row.type == 0) {
                            text = "自定义";
                            styles.backgroundColor = "#bbbec4";
                        } else {
                            styles.backgroundColor = "#5cb85c";
                        }
                        return h("div", [
                            h("span", { style: styles }, text)

                        ]);
                    }
                }

                , {
                    title: '操作',
                    key: 'state',

                    align: 'center',
                    render: (h, params) => {
                        var row = params.row;
                        var btns = [];
                        if (row.type == 0)
                            btns.push(h("Button", { style: { marginRight: "5px" }, props: { size: "small", type: "error" }, on: { click: () => { this.delete(row.id); } } }, "删除"));
                        btns.push(h("Button", { style: { marginRight: "5px" }, props: { size: "small", }, on: { click: () => { this.edit(row); } } }, "修改"));

                        return h("div", btns);
                    }
                }

            ]
        };
    },
    mounted: function() {
        this.getList();

    },
    methods: {
        cbtime: function(value) {
            this.others;
        },
        search: function() {
            this.page.current = 1;
            this.page.total = 0;
            this.getList();
        },
        reset: function() {
            this.queryParams = {};
        },
        changePage(current) {
            this.page.current = current;
            this.getList();
        },
        getList: function() {
            var me = this;
            var params = me.queryParams;
            params.current = me.page.current;
            params.pageSize = me.page.pageSize;
            me.loading = true;
            me.$http.post("/sys/wxmsgreply/getList.action", params).then(response => {
                var body = response;
                if (body.status == 0) {
                    me.page.total = body.obj.totalCount;
                    me.wxMsgReplys = body.obj.list;

                }
                me.loading = false;
            }, response => {
                me.loading = false;
            });
        },
        delete: function(id) {
            var me = this;
            me.$Modal.confirm({
                title: "提示",
                content: "是否执行该操作",
                onOk: function() {
                    me.$http.post("sys/wxmsgreply/doDelete.action", { id: id }).then(response => {
                        var body = response;
                        if (body.status == 0) {
                            me.getList();

                        } else {
                            me.errorMessage("操作异常!" + body.info);
                        }
                    }, response => {

                    });
                },
                onCancel: function() {

                }
            });
        },
        edit: function(row) {
            this.$router.push({ name: 'WxMsgReplyEdit', params: { wxMsgReplyId: row.id } });
        },
        add: function() {
            this.$router.push({ name: 'WxMsgReplyAdd' });
        }
    }
}
</script>
<style scoped>
</style>